# celery启动文件
from celery import Celery

# 创建实例
# meiduo  celery框架名

celery_app = Celery('meiduo', broker='redis://127.0.0.1:6379/15')  # 15号库


@celery_app.task()
def send_sms_code(mobile, sms_code, ext):
    import time
    import os
    import sys
    project_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))  # 工程根目录
    print(project_path)
    sys.path.insert(0, os.path.join(project_path, 'meiduo'))
    from libs.rl_sms import send_message
    # 发送短信验证码
    time.sleep(5)
    send_message(mobile, sms_code, ext)


@celery_app.task()
def add(x, y):
    import time
    print(x, y)
    time.sleep(5)
    return x + y

# 启动celery
# 进入celery_task目录
# celery -A main worker -l info
